package com.system.orders.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.system.common.bean.Orders;
import com.system.common.service.IOrdersService;
import com.system.orders.mapper.OrdersMapper;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

@DubboService
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements IOrdersService {
    @Override
    public Orders getOrdersById(Integer id) {
        return super.getById(id);
    }

    @Override
    public void addOrders(Orders orders) {
        super.save(orders);
    }

    @Override
    public void updateOrders(Orders orders) {
        super.updateById(orders);
    }

    @Override
    public void deleteOrders(Integer id) {
        super.removeById(id);
    }

    @Override
    public Orders getOrdersByOrderNo(String orderNo) {
        LambdaQueryWrapper<Orders> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Orders::getOrderno, orderNo);
        return super.getOne(queryWrapper);
    }

    @Override
    public List<Orders> getOrdersList() {
        return super.list();
    }

    @Override
    public IPage<Orders> getPage(Orders orders, Page<Orders> page) {
        LambdaQueryWrapper<Orders> queryWrapper = new LambdaQueryWrapper<>();
        return baseMapper.selectPage(page, queryWrapper);
    }
}
